package com.learn.springlearn.controller;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("export")
public class ExpotController {




    @RequestMapping()
    public void export(HttpServletResponse response) throws IOException {
        SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook();
        Sheet sheet = sxssfWorkbook.createSheet("公司");
        Sheet sheet1 = sxssfWorkbook.createSheet("员工");
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.addHeader("Content-Disposition", "attachment;filename=fileName" + ".xlsx");
        ServletOutputStream outputStream = response.getOutputStream();
        sxssfWorkbook.write(outputStream);
        outputStream.flush();

    }
}
